<template>
  <el-main style="overflow-x:hidden;">
    <div style="width: 100%; height: 67%;">
      <el-row :gutter="20" style="height:100%; padding-top: 20px;">
        <el-col :span="18" style="height:100%; " >
          <!-- 轮播图 -->
          <div style="height: 100%">
            <el-carousel indicator-position="inside">
              <el-carousel-item v-for="item in imgArr" :key="item">
                <img :src="item" alt="" />
              </el-carousel-item>
            </el-carousel>
          </div>
        </el-col>
        <el-col :span="6"  style="height:100%; ">
          <!-- 右栏内容 -->
          <div class="right">
            <div class="right-title">行动报告</div>

            <ul>
              <li v-for="item in list" :key="item.id" style="list-style: disc">
                <spanm style="width: 30px; white-space: nowrap">{{
                  els(item.goodsName)
                }}</spanm
                ><span class="time">{{
                  timestampToTime(item.huodongshijian)
                }}</span>
                <!-- {{ item.id }} -->
              </li>
            </ul>
          </div>
        </el-col>
      </el-row>
    </div>

    <div class="bottom">
      <el-row :gutter="10">
        <el-col :span="6">
          <div class="grid-content bg">
            <div class="card-title">
              <p>今日待处理事件</p>
            </div>
            <div class="card-content">
              <div>26</div>
              <div class="card-img">
                <img src="../../../asset/images/t1.png" alt="" />
              </div>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="grid-content bg2">
            <div class="card-title">
              <p>今日已处理事件</p>
            </div>
            <div class="card-content">
              <div>15</div>
              <div class="card-img">
                <img src="../../../asset/images/t2.png" alt="" />
              </div>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="grid-content bg3">
            <div class="card-title">
              <p>本周已处理事件</p>
            </div>
            <div class="card-content">
              <div>298</div>
              <div class="card-img">
                <img src="../../../asset/images/t3.png" alt="" />
              </div>
            </div>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="grid-content bg4">
            <div class="card-title">
              <p>本月已处理事件</p>
            </div>
            <div class="card-content">
              <div>1150</div>
              <div class="card-img">
                <img src="../../../asset/images/t4.png" alt="" />
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </el-main>
</template>
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import axios from "axios";
import "@/mock/mock.js";
import { indexApi } from "../../../api/api";
//轮播图
import imgs from "@/asset/images/1.jpg";
import imgs2 from "@/asset/images/2.jpg";
import imgs3 from "@/asset/images/3.jpg";
import imgs4 from "@/asset/images/4.jpg";
import imgs5 from "@/asset/images/5.jpg";

const imgArr = ref([imgs, imgs2, imgs3, imgs4, imgs5]);
//右栏动态内容

const list = ref<any>([]);
const currentPage = ref(1);
const getData = async () => {
  const res = await indexApi({ currentPage: currentPage.value, pageSize: 20 });
  list.value = res.data.result;
};
onMounted(() => {
  getData();
});

const els = (value: any) => {
  if (value.length > 7) {
    return value.slice(0, 7) + "...";
  }
  return value;
};

function timestampToTime(timestamp: any) {
  var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000

  const Y = date.getFullYear() + "-";

  const M =
    (date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1) + "-";

  const D = date.getDate() + " ";

  return Y + M + D;
}
</script>
<style lang="less" scoped>
.el-main {
  flex: 1;
  height: 100%;
  background-color: #f5f5f5;

  :deep(.el-carousel__button) {
    width: 20px;
    height: 20px;
    border-radius: 50%;
  }
  .el-carousel__item h3 {
    display: flex;
    color: #475669;
    opacity: 0.75;
    // line-height:500px ;
    margin: 0;
  }

  .el-carousel {
    height: 100%;
    border-radius: 2%;
    
  }
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
    height: 100%;
  }

  .el-carousel__item:nth-child(2n + 1) {
    background-color: #d3dce6;
    height: 100%;
  }
  :deep(.el-carousel__container) {
   height:100%;

  }
// .el-carousel__indicators {
//   position: absolute;
//   bottom: 0;
//   left: 50%;
//   transform: translate(-50%);
// }
  img {
    width: 100%;
    height: 100%;
  }

  .right {
    border-radius: 3%;
    background-color: white;
    height: 100%;
    // padding-left: 40px;
    padding-right: 10px;
    padding-top: 20px;
    font-size: 12px;
    overflow: hidden;
    ul {
      padding-left: 30px;
    }
     .time {
      margin-left: 22%;
      color: #9a9aaa;
      .ell();
    }
    .right-title {
      font-size: 28px;
      border-bottom: 1px solid #475669;
      line-height: 60px;
      margin-left: 10px;
    }
  }
  .right li {
    line-height: 40px;
    font-size: 12px;
    a {
      .ell();
    }
  }

  .bottom {
    width: 100%;
    height: 30%;
    margin: 20px 0 0px 0;
    .grid-content {
      height: 200px;
      border-radius: 8%;
      background-repeat: no-repeat;
      background-size: cover;
    }
    .card-title {
      font-size: 24px;
      padding: 30px 0 0 50px;
      color: #fff;
    }
    .card-content {
      font-size: 60px;
      font-weight: 500;
      color: #fff;
      padding: 5px 0 0 50px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .card-content img {
      width: 100%;
      height: 100%;
    }
    .card-img {
      width: 150px;
      height: 150px;
      padding-bottom: 20px;
    }
    .bg {
      background-image: url("../../../asset/images/dd1.jpg");
    }

    .bg2 {
      background-image: url("../../../asset/images/dd2.jpg");
    }
    .bg3 {
      background-image: url("../../../asset/images/dd3.jpg");
    }
    .bg4 {
      background-image: url("../../../asset/images/dd4.jpg");
    }
  }
}
</style>
